/*
   @Copyright:LeetCode
   @Author:   tjyemail
   @Problem:  http://leetcode.com/problems/majority-element
   @Language: C++
   @Datetime: 19-11-27 16:19
   */

class Solution {
public:
	int majorityElement(vector<int>& nums) {
		int major, count=0;
		for(const int &num:nums){
			if(count==0) major=num;
			count+=(major==num?1:-1);
		}
		return major;
	}
};
